// myMixin.js
import {
	emojiList
} from '@/common/emoji.js'
import {

} from '@/common/http/api.js'
const config = require('./config')
export const globalMixin = {
	data() {
		return {
			ossUrl: config.url,
			isAuthMixi: false
		};
	},
	created() {

	},
	onShow(){
		let token = uni.getStorageSync('token')
		if(token) {
			this.isAuthMixi = true
		} else {
			this.isAuthMixi = false
		}
	},
	onShareAppMessage() {
		let userInfo = uni.getStorageSync('userInfo')
		if(userInfo) {
			return {
				title: '随美慈铭',
				path:'/pages/index/index?userId=' + userInfo.id
			};
		}
		return {
			title:'随美慈铭',
			path:'/pages/index/index'
		};
	},
	//收藏
	onAddToFavorites(res) {
		let userInfo = uni.getStorageSync('userInfo')
		if(userInfo) {
			return {
				title: '随美慈铭',
				query:'userId=' + userInfo.id
			};
		}
		return {
			title:'随美慈铭',
		};
	},
	methods: {
		isValid(value) {
			if (Array.isArray(value) && value.length === 0) {
				return false
			}
			return value !== undefined && value !== null && value !== '';
		},
		// 点击图片预览时触发的方法
		MpreviewImage(arr) {
			// UniApp中调用微信小程序原生API
			uni.previewImage({
				//current: imageUrls[index], // 当前显示图片的链接
				urls: arr // 需要预览的图片链接列表
			});
		}
	}
};